package com.example.demo.controller.admin;

import com.example.demo.R.Result;
import com.example.demo.domin.Vo.ChartVo;
import com.example.demo.domin.Vo.Dieases;
import com.example.demo.service.admin.IChartService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.text.ParseException;
import java.util.List;

@RestController
@RequestMapping("/admin/analytics")
public class ChartController {

    @Autowired
    private IChartService chartService;

    @GetMapping("/daily_users")
    public Result<List<ChartVo>> DailyUser(@RequestParam("start_date") String startDate, @RequestParam("end_date") String endDate) throws ParseException {
        return chartService.daily(startDate, endDate);
    }
    @GetMapping("/active-users/gender")
    public Result<List<ChartVo>> activeUsers(@RequestParam("start_date") String startDate, @RequestParam("end_date") String endDate){
        return chartService.activeUsers(startDate,endDate);
    }
    @GetMapping("/disease-statistics")
    public Result<List<ChartVo>> diseaseCount(@RequestParam("start_date") String startDate, @RequestParam("end_date") String endDate) throws ParseException {
        return chartService.diseaseCount(startDate, endDate);
    }

    @GetMapping("/hot-diseases")
    public Result<List<Dieases>> hotDiseases() throws ParseException {
        return chartService.hotDiseases();
    }
}
